package org.practice.proxy.subclass;

import java.lang.reflect.Method;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

public class BusinessInterceptorHandler implements MethodInterceptor{

	//该方法用业封装proxy对象的业务逻辑
	public Object intercept(Object proxy, Method method, Object[] args,MethodProxy mp) throws Throwable {
		String name = method.getName();
		System.out.println("========"+name);
		if (name.startsWith("do")) {
			System.out.println("proxy do something(如：Hibernate访问数据库)...");
		}
		// 调用代理对象父类的该方法
		return mp.invokeSuper(proxy, args);
	}
	
}
